<template>
  <div id="app">
    <div class="main">
      <div class="header">
        <van-tabs v-model:active="active">
          <van-tab v-for="item in contents" :key="item.key" :title="item.title">
          </van-tab>
        </van-tabs>
      </div>
      <div class="content_main">
        <div
          class="general"
          v-for="(general, index) in contents[active].list"
          :key="index"
          @click="getSkill(index)"
        >
          <p>
            <img :src="getImgurl(general.avatar as string)" alt="" />
          </p>
          <span>{{ general.name }}</span>
        </div>
      </div>
      <van-dialog
        v-if="showDialog"
        v-model:show="showDialog"
        :title="skillName"
        confirm-button-text="返回"
        confirm-button-color="#BF9D5E"
        width="100vw"
      >
        <component :is="components[active][current]"></component>
      </van-dialog>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from "vue";
import { getImgurl } from "./utils/getAssetsFile.ts";
import { contents } from "../src/utils/data.ts";
// 神
import dinghan from "./components/shen/dinghan.vue";
// 魏
import qiaosi from "./components/wei/qiaosi.vue";
import sidi from "./components/wei/sidi.vue";
import jinglue from "./components/wei/jinglue.vue";
import fujian from "./components/wei/fujian.vue";
// 蜀
import tiansuan from "./components/shu/tiansuan.vue";
// 群
import langxi from "./components/qun/langxi.vue";
import yufeng from "./components/qun/yufeng.vue";
import taoluan from "./components/qun/taoluan.vue";
import xionghuo from "./components/qun/xionghuo.vue";
// 谋弈
import qizhengxiangsheng from "./components/mou/qizhengxiangsheng.vue";
import tieqi from "./components/mou/tieqi.vue";
import duanliang from "./components/mou/duanliang.vue";

const showDialog = ref<boolean>(false);
const active = ref<number>(0);
const current = ref<number>(0);

// 技能组
const components = [
  [qiaosi, sidi, jinglue, fujian],
  [tiansuan],
  [langxi, yufeng, taoluan, xionghuo],
  [dinghan],
  [qizhengxiangsheng, tieqi, duanliang],
];

const skillName = computed(() => {
  return contents[active.value].list[current.value].skillName;
});

const getSkill = (index: number): void => {
  showDialog.value = true;
  current.value = index;
};
</script>

<style scoped lang="scss">
.header {
  height: 100rem;
  background-color: rgba(0, 0, 0, 0.75);
}
.main {
  height: 100vh;
  background: url("../src/assets/background.jpg");
  .header {
    :deep(.van-tabs) {
      height: 100%;
      .van-tabs__wrap {
        height: 100%;
      }
      .van-tab {
        font-size: 40rem;
        height: 100%;
        line-height: normal;
      }
    }
  }
  .content_main {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    .general {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 250rem;
      height: 200rem;
      margin-top: 30rem;
      p {
        width: 150rem;
        height: 150rem;
        border-radius: 50%;
        border: 2rem solid #bf9d5e;
        overflow: hidden;
        img {
          width: 100%;
        }
      }
      span {
        margin-top: 10rem;
        font-size: 30rem;
        font-weight: bold;
        text-align: center;
      }
    }
  }
}
</style>
<style lang="scss">
.van-dialog__content {
  padding: 20rem 10rem;
}
</style>
